/**
 * Created by Admin on 2017/4/17.
 */
$(function () {
    findAllCars(0);
    $("#address li").each(function(){
        $(this).click(function(){
            getAjax("/comm/list_area/"+this.value+"/0/0",findSuccess,errorComm);
        })
    })
    $("#carMoney li").each(function(){
        $(this).click(function(){
            if(this.value=="0"){
                getAjax("/comm/list_between_price/get/0/10/0/0",findSuccess,errorComm);
            }else if(this.value=="1"){
                getAjax("/comm/list_between_price/get/11/20/0/0",findSuccess,errorComm);
            }else if(this.value=="2"){
                getAjax("/comm/list_between_price/get/21/40/0/0",findSuccess,errorComm);
            }else if(this.value=="3"){
                getAjax("/comm/list_between_price/get/41/9999/0/0",findSuccess,errorComm);
            }

        })
    })
    $("#transCount li").each(function(){
        $(this).click(function(){
            if(this.value=="0"){
                getAjax("/comm/list_transfer_count/0/0/0",findSuccess,errorComm);
            }else if(this.value=="1"){
                getAjax("/comm/list_transfer_count/1/0/0",findSuccess,errorComm);
            }else if(this.value=="2"){
                getAjax("/comm/list_transfer_count/2/0/0",findSuccess,errorComm);
            }else{
                getAjax("/comm/list_transfer_count/3/0/0",findSuccess,errorComm);
            }

        })
    })
    $("#sub").click(function(){
        getAjax("/comm/list_car_name/"+$("#carXinghao")[0].value+"/0",findSuccess,errorComm);

        })
})
function findAllCars(id){

    getAjax("/comm/index_get/"+id,findSuccess,errorComm);
}
function findSuccess(content){
    $("#contents").empty();
    // $("#contents").empty();
    // var content=JSON.parse(result);
    for(var i=0;i<content.cars.length;i++){

        var imags=content.cars[i].images.split(",");
        var imgInfo=imags[0];
        var descript=content.cars[i].carMasterDescription;
        var saleMoney=content.cars[i].saleMoney;
        var carId=content.cars[i].id;

        $("#contents").append(
            "<li>"
            +"   <div class='thumbnail' style='height: 222px;width: 200px'>"
            +"     <img alt='250x250' height='150px' width='150px' src='../static/images/"+imgInfo+"' />"
            +"     <div class='caption'>"
            +" 汽车的描述："+content.cars[i].appliedOrderId.carXinghao+""
            +"         汽车的描述："+descript+""
            +"      <br>"
            +"          售卖价格："+saleMoney+"&nbsp;&nbsp;万元"
            +"      <a class='btn btn-primary' href='/car_option/search_car_info?carId="+carId+"'>"
            +"浏览"
            +"</a> "
            +"      </p>"
            +"     </div>"
            +"   </div>"
            +"</li>"
        );
    }

}
function errorComm(error) {

}
// function createCarTemplate(imgInfo,descript,saleMoney,carId) {
//     +"<li class='span4'>"
//     +"   <div class='thumbnail'>"
//     +"     <images alt='300x400' src='../static/images/'"+imgInfo+" />"
//     +"     <div class='caption'>"
//     +"      <h3>"
//     +"         汽车的描述："+descript+""
//     +"      </h3>"
//     +"      <p>"
//     +"          售卖价格："+saleMoney+""
//     +"      </p>"
//     +"      <p>"
//     +"      <a class='btn btn-primary' href='/car_ooption/search_car_info?carId='"+carId+">浏览</a> "
//     +"      </p>"
//     +"     </div>"
//     +"   </div>"
//     +"</li>"
// }
